/*
 * Copyright 2010 Assert Developments
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package be.ad.coffeebreak.domain;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;

/**
 * @author Stefan Bangels
 */
@Entity
@Table(name = "PROJECTS")
@SequenceGenerator(name = "PROJECT_SEQ", sequenceName = "PROJECT_SEQ")
@NamedQueries(value = {
        @NamedQuery(name = Project.QUERY_FIND_PROJECTS_BY_USER_ID,
                query = "SELECT p FROM Project p WHERE p.userId = :" + Project.QUERY_PARAM_USER_ID)
})
@XmlRootElement
public class Project implements Serializable {

    // Queries
    public static final String QUERY_FIND_PROJECTS_BY_USER_ID = "Project#findProjectsByUserId";

    // Query parameters
    public static final String QUERY_PARAM_USER_ID = "userId";

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROJECT_SEQ")
    private Long id;
    @NotNull
    @Column(nullable = false)
    private Long userId;
    @NotNull
    @Column(nullable = false)
    private String name;
    private String description;
    private boolean archived;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public boolean isArchived() {
        return archived;
    }

    public void setArchived(boolean archived) {
        this.archived = archived;
    }

    @Override
    public String toString() {
        return "Project{" +
                "id=" + id +
                ", userId=" + userId +
                ", name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", archived='" + archived + '\'' +
                '}';
    }

}
